package com.acme.bankapp.service.bank;

import com.acme.bankapp.domine.client.*;
import com.acme.bankapp.domine.bank.*;
import com.acme.bankapp.domine.account.*;
import com.acme.bankapp.exceptions.ClientExistsException;
import com.acme.bankapp.exceptions.NoEnoughFundsException;
import com.acme.bankapp.exceptions.OverDraftLimitExceededException;

public class BankApplication {

    public static void main(String[] args) {
        Bank bank = BankService.createNewBank();
        Client client1 = null;
        Client client2 = null;

        try {
            Account account1 = new SavingAccount(1, 100);
            Account account2 = new CheckingAccount(2, 100, 10);
            Account account3 = new SavingAccount(3, 50);
            Account account4 = new CheckingAccount(4, 75, 20);

            try {
                client1 = BankService.addClient(bank, "John", Gender.MALE);
                client2 = BankService.addClient(bank, "Miranda", Gender.FEMALE);
                client1.addAccount(account1);
                client1.addAccount(account2);
                client2.addAccount(account3);
                client2.addAccount(account4);
            } catch (ClientExistsException e) {
                System.out.println(e.getMessage());
            }

            account1.deposit(100);
            try {
                account3.withdraw(50);
                account4.withdraw(800);
            } catch (OverDraftLimitExceededException e) {
                System.out.println(e.getMessage());
            } catch (NoEnoughFundsException e) {
                System.out.println(e.getMessage());
            }

        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }



        BankService.printBalance(bank);
        BankService.printMaximumAmountToWithdraw(bank);
    }
}
